# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=hyperfine
pkgver=1.14.0
pkgrel=0
pkgdesc="Command-line benchmarking tool"
url="https://github.com/sharkdp/hyperfine"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"  # blocked by cargo/rust
license="Apache-2.0 AND MIT"
makedepends="cargo"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="https://github.com/sharkdp/hyperfine/archive/v$pkgver/$pkgname-$pkgver.tar.gz"

export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"
export CARGO_PROFILE_RELEASE_PANIC="abort"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --frozen --release
}

check() {
	cargo test all --frozen
}

package() {
	install -Dm755 target/release/hyperfine \
		"$pkgdir"/usr/bin/hyperfine
	install -Dm644 doc/hyperfine.1 \
		"$pkgdir"/usr/share/man/man1/hyperfine.1

	install -Dm644 target/release/build/hyperfine-*/out/hyperfine.bash \
		"$pkgdir/usr/share/bash-completion/completions/hyperfine"
	install -Dm644 target/release/build/hyperfine-*/out/_hyperfine \
		"$pkgdir/usr/share/zsh/site-functions/_hyperfine"
	install -Dm644 target/release/build/hyperfine-*/out/hyperfine.fish \
		"$pkgdir/usr/share/fish/completions/hyperfine.fish"
}

sha512sums="
a79e914fc45b96789422c3f0910eb2593459a53384591c8357539739d9e111c50b6efce0bfacf89d21980d272f637e09813da0e133757e4305f244186021839d  hyperfine-1.14.0.tar.gz
"
